using System.Threading.Tasks;
using JoyfulHomeJourney.BackEnd.Infrastructure.Atrributes;
using JoyfulHomeJourney.BackEnd.Infrastructure.Dtos.Requests.Objects;
using JoyfulHomeJourney.BackEnd.Infrastructure.Dtos.Responses;
using JoyfulHomeJourney.BackEnd.Server.Interfaces;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace JoyfulHomeJourney.BackEnd.Api.Admin.Controllers
{
	[TypeFilter(typeof(CheckLoginFilter), Arguments = new object[] { new string[] { "admin", "carShop" } })]
	public class DictionarysController : BaseController
	{
		private readonly IDictionarysServer _dictionarysServer;
		public DictionarysController(IDictionarysServer dictionarysServer)
		{
			_dictionarysServer = dictionarysServer;
		}
		/// <summary>
		/// 添加
		/// </summary>
		/// <param name="dto"></param>
		/// <returns></returns>
		[HttpPost]
		[ActionLog("添加字典")]
		public async Task<IActionResult> Add(RequestDictionarysDto dto)
		{
			return Send(await _dictionarysServer.AddAsync(dto));
		}
		/// <summary>
		/// 删除
		/// </summary>
		/// <param name="dto"></param>
		/// <returns></returns>
		[HttpPost]
		[ActionLog("删除字典")]
		public async Task<IActionResult> Delete(RequestDictionarysDto dto)
		{
			return Send(await _dictionarysServer.DeleteAsync(dto));
		}
		/// <summary>
		/// 修改
		/// </summary>
		/// <param name="dto"></param>
		/// <returns></returns>
		[HttpPost]
		[ActionLog("修改字典")]
		public async Task<IActionResult> Update(RequestDictionarysDto dto)
		{
			return Send(await _dictionarysServer.UpdateAsync(dto));
		}
		/// <summary>
		/// 分页
		/// </summary>
		/// <param></param>
		/// <returns></returns>
		[HttpGet]
		public async Task<IActionResult> Pagination(int page,int limit)
		{
			return Send(await _dictionarysServer.PaginationAsync(page,limit));
		}
        /// <summary>
        /// 查询客户行业
        /// </summary>
        /// <param></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> GetCustomerIndustry()
        {
            return Send(await _dictionarysServer.GetCustomerIndustry());
        }
        /// <summary>
        /// 查询客户级别
        /// </summary>
        /// <param></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> GetCustomerLevel()
        {
            return Send(await _dictionarysServer.GetCustomerLevel());
        }
        /// <summary>
        /// 查询客户来源
        /// </summary>
        /// <param></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> GetCustomerSource()
        {
            return Send(await _dictionarysServer.GetCustomerSource());
        }
        /// <summary>
        /// 查询跟进方式
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> GetFollowWay()
        {
            return Send(await _dictionarysServer.GetFollowWay());
        }
        /// <summary>
        /// 根据key查询字典
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        [HttpGet]
		public async Task<IActionResult> GetDictionaryListByDictionaryTypeKey(string key)
		{
			return Send(await _dictionarysServer.GetDictionaryListByDictionaryTypeKey(key));
		}
		/// <summary>
		/// 根据key获取树形字典
		/// </summary>
		/// <param name="key"></param>
		/// <returns></returns>
		[HttpGet]
		public async Task<IActionResult> GetDictionaryTreeByDictionaryTypeKey(string key)
		{
			return Send(await _dictionarysServer.GetDictionaryTreeByDictionaryTypeKey(key));
		}
        /// <summary>
        /// 根据父级编号查询字典
        /// </summary>
        /// <param name="parentId"></param>
        /// <returns></returns>
        [HttpGet]
		public async Task<IActionResult> GetDictionaryListByParentId(string parentId)
		{
			return Send(await _dictionarysServer.GetDictionaryListByParentId(parentId));
		}
		/// <summary>
		/// 获取字典详情
		/// </summary>
		/// <param name="id"></param>
		/// <returns></returns>
		[HttpGet]
        public async Task<IActionResult> Detail(string id)
		{
			return Send(await _dictionarysServer.DetailAsync(id));
		}
    }
}
